Delay variable coercion until argument use#688
Draft
vladar wants to merge 4 commits into
Draft
Conversation
Coerce GraphQL variables lazily against the schema fragment available at the field argument call site, and cache each variable result so repeated usages do not re-coerce. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Route getVariableValues through the lazy per-variable coercion path so eager and late coercion cannot diverge. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Keep the root-fragment/input-variable characterization while removing unrelated union output schema from the test fixture. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Input object variable definitions can reference types that are not present in the initial browser-side schema fragment. Eagerly coercing all variables during execution context creation forces those input definitions to be loaded too early.
This changes Supermassive execution to keep raw variable inputs in the execution context and coerce variables lazily when an argument value actually references them, using the schema fragment available at that call site. Coercion results are cached per variable so repeated uses do not re-run scalar parsing or input coercion.
Characterization tests cover loading the root mutation fragment before coercing an input variable, avoiding schema loads for unused input variable definitions, and ensuring a variable used multiple times is coerced only once.
Validation:
packages/supermassivetypecheckyarn workspace @graphitation/supermassive test --runInBand --diagnostics=falseyarn workspace @graphitation/supermassive lint